/* eslint-disable no-console */
/* eslint-disable no-param-reassign */

import { randomInt } from './common';

/**
 * Randomized the input array
 * @param A the array
 * @returns a randomized sorted array
 */
export function randomizeInPlace(A: number[]): number[] {
	const n = A.length;

	for (let i = 0; i < n; i += 1) {
		const randomIndex = randomInt(0, n - 1)
		const value = A[randomIndex]
		A[randomIndex] = A[i]
		A[i] = value
	}

	return A
}

console.log(randomizeInPlace([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]))
